//
//  JPApplyForDoctorCell.m
//  JPKY
//
//  Created by 刘刘 on 16/11/14.
//  Copyright © 2016年 Vitas. All rights reserved.
//

#import "JPApplyForDoctorCell.h"
#import <UIImageView+WebCache.h>

#define LEFTSPACING 8

@interface JPApplyForDoctorCell ()

// 头像
@property (nonatomic, weak) UIImageView *imageV;
// 医院名字
@property (nonatomic, weak) UILabel *nameLabel;
// 性别
@property (nonatomic, weak) UILabel *sexLabel;
// 医院名字
@property (nonatomic, weak) UILabel *hospitalLabel;
// 预约数
@property (nonatomic, weak) UILabel *appointmentLb;

@end

@implementation JPApplyForDoctorCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    // 设置头像
    UIImageView *imageV = [[UIImageView alloc] init];
    [imageV setImage:[UIImage imageNamed:@"mao"]];
    [self addSubview:imageV];
    self.imageV = imageV;
    
    [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.equalTo(self);
        make.width.mas_equalTo(imageV.mas_height).multipliedBy(2/3.0);
    }];
    
    // 医生名字
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"医生名字 : ";
    [self addSubview:nameLabel];
    self.nameLabel = nameLabel;
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(LEFTSPACING);
        make.left.equalTo(imageV.mas_right).offset(8);
    }];
    
    // 性别
    UILabel *sexLabel = [[UILabel alloc] init];
    sexLabel.text = @"性别 : ";
    [self addSubview:sexLabel];
    self.sexLabel = sexLabel;
    
    [sexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLabel.mas_bottom).offset(LEFTSPACING);
        make.left.equalTo(imageV.mas_right).offset(8);
    }];
    
    // 医院名字
    UILabel *hospitalLabel = [[UILabel alloc] init];
    hospitalLabel.text = @"医院名字 : ";
    [self addSubview:hospitalLabel];
    self.hospitalLabel = hospitalLabel;
    
    [hospitalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sexLabel.mas_bottom).offset(LEFTSPACING);
        make.left.equalTo(imageV.mas_right).offset(8);
    }];
    
    // 预约数
    UILabel *appointmentLb = [[UILabel alloc] init];
    appointmentLb.text = @"预约数 : ";
    [self addSubview:appointmentLb];
    self.appointmentLb = appointmentLb;
    
    [appointmentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(hospitalLabel.mas_bottom).offset(LEFTSPACING);
        make.left.equalTo(imageV.mas_right).offset(8);
    }];
}

- (void)setModel:(JPApplyForDoctorModel *)model {
    
    _model = model;
    self.nameLabel.text = [NSString stringWithFormat:@"姓名 : %@",model.doctor_name];
    self.sexLabel.text = [NSString stringWithFormat:@"性别 : %@",model.doctor_gender ? @"男" : @"女"];
    self.hospitalLabel.text = [NSString stringWithFormat:@"医院名称 : %@",model.doctor_hospital_name];
    self.appointmentLb.text = [NSString stringWithFormat:@"预约数 : %zd",model.operation_count];
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:model.doctor_portrait] placeholderImage:model.doctor_gender ? [UIImage imageNamed:@"doctor_defaultphoto_male"] : [UIImage imageNamed:@"doctor_defaultphoto_female"]];
}

/* 
 {
 accuracy = "98%";
 banner = 5;
 "doctor_gender" = 1;
 "doctor_hospital_name" = "\U533b\U79d1\U9662\U80bf\U7624\U533b\U9662";
 "doctor_id" = 200000126;
 "doctor_name" = "\U5f20\U8fde\U6d77";
 "doctor_portrait" = "http://www.bjcancer.org/Sites_OldFiles/Template/default/picture/doctor/5-large.jpg";
 "doctor_title_name" = "\U5176\U4ed6";
 "easymob_id" = d200000126;
 flower = 4;
 "operation_count" = 1;
 }
 */

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
